package cn.web.web_module.service.impl;

import cn.web.web_module.entity.TbAdminRole;
import cn.web.web_module.mapper.TbAdminRoleMapper;
import cn.web.web_module.service.TbAdminRoleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TbAdminRole)表服务实现类
 *
 * @author 小松
 * @since 2020-07-29 10:57:08
 */
@Service("tbAdminRoleService")
public class TbAdminRoleServiceImpl implements TbAdminRoleService {
    @Resource
    private TbAdminRoleMapper tbAdminRoleMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param adminId 主键
     * @return 实例对象
     */
    @Override
    public TbAdminRole queryById(Integer adminId) {
        return this.tbAdminRoleMapper.queryById(adminId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<TbAdminRole> queryAllByLimit(int offset, int limit) {
        return this.tbAdminRoleMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param tbAdminRole 实例对象
     * @return 实例对象
     */
    @Override
    public TbAdminRole insert(TbAdminRole tbAdminRole) {
        this.tbAdminRoleMapper.insert(tbAdminRole);
        return tbAdminRole;
    }

    /**
     * 修改数据
     *
     * @param tbAdminRole 实例对象
     * @return 实例对象
     */
    @Override
    public TbAdminRole update(TbAdminRole tbAdminRole) {
        this.tbAdminRoleMapper.update(tbAdminRole);
        return this.queryById(tbAdminRole.getAdminId());
    }

    /**
     * 通过主键删除数据
     *
     * @param adminId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer adminId) {
        return this.tbAdminRoleMapper.deleteById(adminId) > 0;
    }
}